package com.example.singleactivitytemplate.ui.acts

import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import com.example.singleactivitytemplate.ui.base.BaseViewModel


class SimpleViewModel : ViewModel() {
    var mMode = 1

    fun modeAdd() {
        if (mMode + 1 <= 2) {
            mMode += 1
        }
    }
}

class SimpleViewModelBase : BaseViewModel() {
    var mMode = 1

    fun modeAdd() {
        if (mMode + 1 <= 2) {
            mMode += 1
        }
    }
}

class LiveDataViewModel : ViewModel() {
    val mMode = MutableLiveData<Int>().apply { value = 1 }

    fun modeAdd() {
        mMode.value?.let {
            if (it + 1 <= 2) {
                mMode.value = it + 1
            }
        }
    }
}

class LiveDataViewModelBase : BaseViewModel() {
    val mMode = MutableLiveData<Int>().apply { value = 1 }

    fun modeAdd() {
        if (((mMode.value?.plus(1)) ?: 1) <= 2) {
            mMode.value = (mMode.value?.plus(1))
        }
    }
}